--莱茵充能护符
local laiyinchongnenghufu = fk.CreateSkill {
    name = "mcdh_laiyinchongnenghufu",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

laiyinchongnenghufu:addEffect(fk.EventPhaseStart,{
    can_trigger = function(self, event, target, player, data)
        if target ~= player or not player:hasSkill(self) or player.phase ~= Player.Start then return false end
        return player:getHandcardNum() >= 2
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local cids = room:askForDiscard(
                player,
                2, 2,
                false,
                self.name,
                true,
                ".",
                "#mcdh_laiyinchongnenghufu-choice",
                true
        )
        if #cids > 0 then
            self.cost_data = cids
            return true
        end
        return false
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:throwCard(self.cost_data, self.name, player, player)
        local excludeIds = {}
        for _, p in ipairs(room.alive_players) do
            for _, id in ipairs(p:getCardIds("e")) do
                if Fk:getCardById(id).sub_type ~= Card.SubtypeArmor then
                    table.insert(excludeIds, id)
                end
            end
        end

        local targets = room:askToChooseToMoveCardInBoard(
            player,
            {
                skill_name = self.name,
                cancelable = true,
                flag="e",
                exclude_ids = excludeIds,
                prompt="#mcdh_laiyinchongnenghufu-moveCard",
                
            }
        )
       
        if #targets == 0 then return end
        room:askForMoveCardInBoard(
                player,
                targets[1],
                targets[2],
                self.name,
                "e",
                nil,
                excludeIds
        )
    end
})

Fk:loadTranslationTable {
    ["mcdh_laiyinchongnenghufu"] = "服卫",
    [":mcdh_laiyinchongnenghufu"] = "『莱茵充能护符』<br>准备阶段，你可以弃置两张手牌，然后移动场上的一张防具牌。",
    ["#mcdh_laiyinchongnenghufu-choice"] = "莱茵充能护服：弃置两张手牌，移动场上一张防具牌",
    ["#mcdh_laiyinchongnenghufu-moveCard"] = "莱茵充能护服：移动场上的一张防具牌",
}

return laiyinchongnenghufu